package com.lottery.ruok.lottrey.chat.model.redpacket.message.sendRedPacketMessage.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.lottery.ruok.lottrey.R;
import com.lottery.ruok.lottrey.chat.model.redpacket.message.sendRedPacketMessage.RedPacketMessage;

/**
 * 发红包View
 */
public class RedPacketView extends RelativeLayout {
    private final Context mContext;
    private TextView mRemarkView;
    private TextView mAttachView;
    private RedPacketMessage data;
    private View viewContainer;

    public RedPacketView(Context context) {
        this(context, null);
    }

    public RedPacketView(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public RedPacketView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        mContext = context;
        init();
        initView();
    }

    private void init() {

    }

    private void initView() {
        LayoutInflater.from(mContext).inflate(R.layout.view_red_packet, this);
        mRemarkView = findViewById(R.id.tv_red_packet_remark);
        mAttachView = findViewById(R.id.tv_red_packet_attach);
        viewContainer = findViewById(R.id.view_red_packet);
    }

    public void setData(RedPacketMessage data) {
        this.data = data;
        updateView();
    }

    private void updateView() {
        mRemarkView.setText(data.getContent());
    }

    public void setRedPacketBackgroundResource(int resId) {
        viewContainer.setBackground(mContext.getResources().getDrawable(resId));
    }
}
